package demo1;

public class Student implements Cloneable{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}


class Test{
    public static void main(String[] args) throws CloneNotSupportedException{
        Student stu1 = new Student("zhangsan",14);
        Student stu2 = (Student)stu1.clone();
        System.out.println("stu1:"+stu1);
        System.out.println("stu2:"+stu2);
    }
}